﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ProjectType.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The project type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The project type.
    /// </summary>
    [DataContract]
    public class ProjectType
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is research and development.
        /// </summary>
        [DataMember]
        public bool IsResearchAndDevelopment { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="projectType">
        /// The project type.
        /// </param>
        /// <returns>
        /// The <see cref="ProjectType"/>.
        /// </returns>
        public static ProjectType Convert(Models.Domain.ProjectType projectType)
        {
            if (projectType != null)
            {
                var dto = new ProjectType
                              {
                                  ID = projectType.ID, 
                                  Name = projectType.Name, 
                                  IsResearchAndDevelopment = projectType.IsResearchAndDevelopment
                              };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The project type query.
    /// </summary>
    [DataContract]
    public class ProjectTypeQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new ProjectMeetingActioner(hsession, null);

            return actioner.QueryAllProjectTypes();
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The project type result.
    /// </summary>
    [DataContract]
    public class ProjectTypeResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectTypeResult"/> class.
        /// </summary>
        public ProjectTypeResult()
        {
            this.List = new List<ProjectType>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<ProjectType> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}